#ifndef IMSI_GUI_H
#define IMSI_GUI_H

#include "Defines.h"

extern HINSTANCE Instance;

class Core;

class Ui : boost::noncopyable
{
protected:
    std::vector<String> mSections;
    Core& mCore;

protected:
    bool NextCommandEvent();
    bool BackCommandEvent();
    bool ShouldSkipSectionEvent(const String& aSection);
    int IndexOfSection(const String& aSection);
    virtual void ShowSection (const String& aSection) = 0;
    // Run is not allowed to return until the installation is finished
    virtual void Run() = 0;
    virtual void SetLabelTextForSection(const String& aSection, const String& aLabel, const String& aText) = 0;
    virtual String NameOfCurrentSection() = 0;

public:
    Ui (Core& aCore);
    virtual ~Ui();

    const std::vector<String>& Sections () const
    {
        return mSections;
    }
    void MoveToSection(const String& aSection)
    {
        ShowSection(aSection);
    }

    void Start() { Run(); }
    void SetLabelText(const String& aSection, const String& aLabel, const String& aText) { SetLabelTextForSection(aSection, aLabel, aText); }
    String CurrentSection() { return NameOfCurrentSection(); }
};

class WizardPage
{
protected:
    HWND mHandle;
    PROPSHEETPAGE* mPagaData;

public:
    WizardPage (HWND aHandle, PROPSHEETPAGE* aPagaData)
        : mHandle (aHandle), mPagaData (aPagaData)
    {  }

    const _TCHAR* Title () const
    {
        return mPagaData->pszHeaderTitle;
    }

    const _TCHAR* SubTtle () const
    {
        return mPagaData->pszHeaderSubTitle;
    }

    void SetSubTitle (const _TCHAR* aText)
    {
        int Index = PropSheet_HwndToIndex (GetParent (mHandle), mHandle);
        PropSheet_SetHeaderSubTitle (GetParent (mHandle), Index, aText);
    }
};

#endif // IMSI_GUI_H
